package com.limao.DBProvider;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;

import com.limao.DBDataClass.SysSmsDataClass;
import com.limao.DbConnection.DbConnectionManager;

public class SysSmsProvider {
	
	private static SysSmsProvider instance;

	public static SysSmsProvider getInstance() {
		if(instance==null) instance=new SysSmsProvider();
		return instance;
	}
	
	 public ArrayList<SysSmsDataClass> Load_SysSms()
	 {
		 	ArrayList<SysSmsDataClass> list=new ArrayList<SysSmsDataClass>();
			Connection con = null;
			PreparedStatement pstmt = null;
			ResultSet rs = null;
			try {
				con = DbConnectionManager.getConnection();
				pstmt = con.prepareStatement("select * from cd_sys_sms where state=1 order by msgid desc ");
				rs = pstmt.executeQuery();
				while (rs.next()) {
					SysSmsDataClass tmp = new SysSmsDataClass();
					tmp.msgid= rs.getString("msgid");
					tmp.type= rs.getString("type");
					tmp.msgtxt= rs.getString("msgtxt");
					tmp.state= rs.getString("state");
					tmp.createtime= rs.getString("createtime");
					tmp.updatetime= rs.getString("updatetime");
					list.add(tmp);
				}

			} catch (Exception e) {
				list.clear();
				e.printStackTrace();
			} finally {
				DbConnectionManager.closeConnection(rs, pstmt, con);
			}
			return list;
	 }
	 
}
